package sicnu.cs.ich.log.canal;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import sicnu.cs.ich.api.common.Constants;
import sicnu.cs.ich.api.domain.entity.Ich;
import top.javatool.canal.client.annotation.CanalTable;
import top.javatool.canal.client.handler.EntryHandler;

/**
 * @author CaiKe
 * @date 2021/12/10 16:00
 */
@Slf4j
@Component
@CanalTable(value = "t_ich")
@RequiredArgsConstructor
public class IchHandler extends BaseHandler<Ich> implements EntryHandler<Ich> {

    @Override
    public void insert(Ich ich) {
//        log.info("插入：{}",ich);
        deleteCache(item -> Constants.REDIS_ICH + item.getId(), ich);
    }

    @Override
    public void update(Ich before, Ich after) {
//        log.info("修改：{} 为 {}",before, after);
        deleteCache(item -> Constants.REDIS_ICH + item.getId(), after);
    }

    @Override
    public void delete(Ich ich) {
//        log.info("删除：{}",ich);
        deleteCache(item -> Constants.REDIS_ICH + item.getId(), ich);

    }

}